<div class="dtree">
	<?php
		echo ' <script type="text/javascript"> ';
		echo ' d = new dTree(\'d\'); ';
		echo ' d.add(0,-1,\'Sites\',\'?con='.$_REQUEST['con'].'\',\'\',\'\',\'img/base_comp.gif\',\'img/base_comp.gif\'); ';
		$k=0;
		$x=0;
		$j=1;
		$sites  = getSitesList();
		if($sites)
		{
			foreach($sites as $site)
			{
				echo ' d.add('.$j.',0,\''.$site['title'].'\',\'?con='.$_REQUEST['con'].'&amp;site='.$site['id'].'\',\'\',\'\',\'img/globe.gif\',\'img/globe.gif\'); ';
				$k = $j;
				$x = $j;
				$j++;
				$templates = getContentTemplates($site['id']);
				if($templates)
				{
					foreach($templates as $template)
					{
						echo ' d.add('.$j.','.$x.',\''.$template['title'].'\',\'?con=11&amp;item='.$template['id'].'\',\'\',\'\',\'img/imgfolder.gif\',\'img/imgfolder.gif\'); ';
						$pcon = $j;
						$j++;
						$lists  = getContentList($template['id']);
						if($lists)
						{
							$i=1;
							foreach($lists as $node)
							{
								if($node['parent_id'] == $template['id'])
								{
									?>
									<?php
									echo "d.add(".$j.",".$pcon.",'List ".$i."','');";
									$pnode = $j;
									$j++;
									?>
									<?php
									if($node['items'])
									{
										$k=1;
										foreach($node['items'] as $node_item)
										{
											?>
											<?php
											echo "d.add(".$j.",".$pnode.",'Item ".$k."','');";
											$j++;
											$k++;
											?>
											<?php
										}
									}
								}
								$i++;
							}
						}
					}
				}
			}				
		}
		echo ' document.write(d); ';
		echo ' </script> ';
	?>
</div>